package com.boss.asset.dao.impl;

import com.boss.asset.dao.IAssetExtDao;
import com.boss.asset.entity.BasAssetExt;
import com.boss.framework.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AssetExtDaoImpl extends BaseDaoImpl implements IAssetExtDao {

    private final static String TABLE_NAME = "BAS_ASSET_EXT";

    @Override
    public void insert(BasAssetExt data) {
        StringBuilder sql = new StringBuilder();
        sql.append("INSERT INTO ").append(TABLE_NAME);
        sql.append("(ASSET_ID,BIZ_KEY,OFFICE_HOUSE_AREA,BISNISS_HOUSE_AREA,OTHER_HOUSE_AREA,")
                .append("LOC,PRO_STA_DATE,PRO_CONS_STA,OWNERSHIP_CERT,LAND_CERTIFI_DATE,")
                .append("LAND_NO,LAND_OWNERSHIP_AREA,STRUCTURE_AREA,USE_AREA,VEHICLE_TRAV_LICENCE_INFO,")
                .append("VEHICLE_OWNER,VEHICLE_REGIS_DATE,VEHICLE_IDENTI_CODE,VEHICLE_LICENCE_NO,VEHICLES_NUM,")
                .append("HOUSE_OWNERSHIP_CERT,HOUSE_OWNER,HOUSE_OWNERSHIP_NO,HOUSE_OWNERSHIP_AREA,START_DATE,")
                .append("END_DATE,UPDATE_TIME,FLOOR_AREA,IS_DELETED,FI_LEADER,")
                .append("SERVICE_LIFE,DEPRECIATION_METHOD,POSTER_DATE,ACCOUNTING_STATUS,VOUCHER_NO,")
                .append("IS_SHARED_PLATFORM,IS_SHARING,CREATE_TIME,VEHICLE_TYPE,VEHICLE_NUMB,")
                .append("VEHICLE_SPE,VEHICLE_LAW,VEHICLE_MOD,INVESTED_AGENCY_INFO,INVESTED_AGENCY_STOCK_NO,")
                .append("IS_INVESTED_AGENCY_IN_MARKET,INVESTED_AGENCY_ORG_FORM_CODE,STOCK_PERC,FINAL_INVEST_AMT,CUR_INVEST_AMT,")
                .append("PAR_VAL_AMT,TOTAL_INVES,ACC_INVES,PRES_YEAR_INVES,STA_USE_DATE,")
                .append("NO_REG_ASSET_REASON,ACQU_DATE,INVESTED_AGENCY_CODE,INVESTED_PRO_NAME,OFFICAL_VEH,IS_FISCAL)");
        sql.append("VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,")
                .append(" ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");

        Object[] params = new Object[]{
                data.getAssetId(), data.getBizKey(), data.getOfficeHouseArea(), data.getBissnissHouseArea(), data.getOtherHouseArea(),
                data.getLoc(), data.getProStaDate(), data.getProConsSta(), data.getOwnershipCert(), data.getLandCertifiDate(),
                data.getLandNo(), data.getLandOwnershipArea(), data.getStructureArea(), data.getUseArea(), data.getVehicleTravLicenceInfo(),
                data.getVehicleOwner(), data.getVehicleRegisDate(), data.getVehicleIdentiCode(), data.getVehicleLicenceNo(), data.getVehiclesNum(),
                data.getHouseOwnershipCert(), data.getHouseOwner(), data.getHouseOwnershipNo(), data.getHouseOwnershipArea(), data.getStartDate(),
                data.getEndDate(), data.getUpdateTime(), data.getFloorArea(), data.getIsDeleted(), data.getFiLeader(),
                data.getServiceLife(), data.getDepreciationMethod(), data.getPosterDate(), data.getAccountingStatus(), data.getVoucherNo(),
                data.getIsSharedPlatform(), data.getIsSharing(), data.getCreateTime(), data.getVehicleType(), data.getVehicleNumb(),
                data.getVehicleSpe(), data.getVehicleLaw(), data.getVehicleMod(), data.getInvestedAgencyInfo(), data.getInvestedAgencyStockNo(),
                data.getIsInvestedAgencyInMarket(), data.getInvestedAgencyOrgFormCode(), data.getStockPerc(), data.getFinalInvestAmt(), data.getCurInvestAmt(),
                data.getParValAmt(), data.getTotalInves(), data.getAccInves(), data.getPresYearInves(), data.getStaUseDate(),
                data.getNoRegAssetReason(), data.getAcquDate(), data.getInvestedAgencyCode(), data.getInvestedProName(), data.getOfficalVeh(),data.getIsFiscal()
        };
        this.getJdbcTemplate().update(sql.toString(), params);
    }

    @Override
    public void dropAssetExtByIds(List<String> idList) {
        StringBuilder sql = new StringBuilder();
        sql.append("delete from ").append(TABLE_NAME).append(" where ").append(com.boss.sys.utils.SysUtils.inSql("asset_id", idList));
        this.getJdbcTemplate().update(sql.toString(), new Object[]{});
    }
}
